package service;
import java.util.ArrayList;
import java.util.List;
import dao.OrderDao;
import dao.OrderItemDao;
import entity.Order;
import entity.OrderItem;

public class OrderItemService {

	OrderItemDao orderItemDao = new OrderItemDao();

	public List<OrderItem> findAllOrderByBookid(String id) {
		List<OrderItem> list = orderItemDao.findAllOrderByBookid(id);
		return list;
	}

	public List<OrderItem> findAllOrderItemByUserId(String id) {
		List<OrderItem> orderItems = new ArrayList<OrderItem>();
		List<Order> orders = new OrderDao().findallByUserId(id);
		for (Order order : orders) {
			OrderItem orderItem = new OrderItemDao().findOrderItemByOrderId(order.getId(),id);
			orderItem.setOrder(order);
			orderItems.add(orderItem);
		}
		return orderItems;
	}
	
	
	
}
